#ifndef DATAMODEL_H
#define DATAMODEL_H

#include <QAbstractTableModel>
#include <QList>
#include <QSqlQuery>

class DataModel : public QAbstractTableModel
{
	Q_OBJECT
private:
	class TableEntry{
	public:
		QString title;
		int id;
		uint timestamp;
		bool readed;
	};

	QList<TableEntry> m_list;

public:
	DataModel(QObject *parent = 0);


	int rowCount(const QModelIndex &parent) const;
	int columnCount(const QModelIndex &parent) const;

	QVariant data(const QModelIndex &index, int role) const;

	QVariant headerData(int section, Qt::Orientation orientation,
						int role = Qt::DisplayRole) const;

	void fillData(QSqlQuery &query);
public slots:
	void itemReaded(const QModelIndex &index);
	void itemDeleted(QList<int> indexes);
	void itemUnreaded(const QModelIndex &index);

signals:
	void markAsReaded( uint id, bool mark );
	void markAsDeleted( uint id, bool mark );
};

#endif // DATAMODEL_H
